package com.eni.dvtejb.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jboss.xnio.log.Logger;

import com.eni.dvtejb.metier.entities.Adresse;
import com.eni.dvtejb.metier.sessions.AdresseDAO;

/**
 * Servlet implementation class TestAdresseDAO
 */
public class TestAdresseDAO extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static final Logger log=Logger.getLogger(TestAdresseDAO.class);
	@EJB(name="VenteEnLigne/AdresseDAOImpl/remote")
	private AdresseDAO adresseDAO;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public TestAdresseDAO() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PrintWriter out=response.getWriter();
		List liste=adresseDAO.findAll();
		for(Object elem : liste){
			Adresse adr=(Adresse)elem;
			out.println(adr.getPays() + "--" + adr.getVille() + "--" + adr.getDepartement() + "--" + adr.getNumero() + "--" + adr.getRue());
			out.println("<br>");
		}
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
